1. Field of the Invention
The invention claimed herein provides an automated process for detecting method calls in a running program that are redundant, in view of one or more previous method calls, and may therefore be unnecessary. More particularly, the invention pertains to a process of the above type that detects the number of times that a method having the same argument or arguments is called. Even more particularly, the invention pertains to a process of the above type wherein redundancies are detected by using hash codes or hash values to uniquely identify each particular argument of respective methods.
2. Description of the Related Art
A profiler is a performance analysis tool that measures behavior of a program as it is being run, such as the frequency and duration of methods, or functions, of the program. Herein, the terms “method” and “function” are used synonymously. At present, Java profilers may employ a call stack to view data that pertains to a running program. The call stack displays program methods in a tree or graph view, with nodes representing method calls. Data, such as cumulative execution time and CPU elapsed time, is typically presented for each method called.
A profiler tool of the above type and the capabilities it provides are useful for helping an analyst to discover opportunities to enhance program performance. However, such tools typically do not enable an analyst to discover calls to a method that are redundant, that is, that are duplicates of a previous call. To illustrate method call redundancy, an exemplary method Foo.mumble(x,y,z) is considered, wherein x, y, and z are the arguments or other parameters of this method. When its program is running, there is a first call to the method, wherein x, y, and z each has a particular value. If there is then a second call to the method, wherein the values of x, y, and z are each identical to their respective values for the first call, the second method call is a duplicate or redundant of the first call, unless there is some necessary intended reason for the identical second call. One such reason could be that the method call Foo.mumble(x,y,z) has side effects. A method or function produces a side effect if it modifies some state in addition to returning a value.
When a redundant or duplicate method call occurs in a running program, a task is performed that was performed previously by the first method call. Frequently, it happens that each of the duplicate calls is unnecessary, because the task only needed to be performed one time. As a simple illustrative example of this, a program executed to perform a number of operations on a table could call a method to paint the table, wherein the method has an argument that causes the table to be painted green. After this task has been completed, it would generally be a waste of time and resources to call the method a second time with the same argument, since this would cause the table to again be painted green. Moreover, redundant method calls that are not necessary uselessly add to the expense of a method, such as by increasing time requirements and/or by consuming memory and CPU capacity. However, typical profilers generally do not capture method arguments, nor do they provide a way to search for redundant calls.